import {
  Captcha,
  LoginFormData,
} from '@/types/api/system/login';
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
// @ts-ignore
import {AUTH_PATH_WEB_PREFIX} from '@/types/store/prefix.d.ts';

/**
 * 登录
 * @param data
 */
export function login(data: LoginFormData): AxiosPromise<string> {
  return request({
    url: AUTH_PATH_WEB_PREFIX + '/account/login/let',
    method: 'post',
    data: data
  });
}

/**
 * 注销
 */
export function logout() {
  return request({
    url: AUTH_PATH_WEB_PREFIX + '/account/logout/let',
    method: 'delete',
  });
}

/**
 * 获取图片验证码
 */
export function getCaptcha(): AxiosPromise<Captcha> {
  return request({
    url: AUTH_PATH_WEB_PREFIX + '/account/login/captcha/let',
    method: 'get',
  });
}
